package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenCheckReasonDTO;
import com.hzeport.bgs22emduty.dto.experience.ScreenDutyExperienceRemoveDTO;
import com.hzeport.bgs22emduty.entity.ScreenCheckReason;
import com.hzeport.bgs22emduty.service.ScreenCheckReasonService;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/screenCheckReason")
@Api(value = "screenCheckReason", tags = "抽查原因管理")
@Slf4j
public class ScreenCheckReasonController {

    private final LoginCompoentService loginCompoentService;

    private final ScreenCheckReasonService screenCheckReasonService;

    @ApiOperation(value = "下拉列表")
    @RequestMapping(value = "pullDownList", method = RequestMethod.GET)
    public BaseResult<List<ScreenCheckReason>> pullDownList() {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenCheckReasonService.pullDownList(userInfoDetailVO);
    }

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list", method = RequestMethod.POST)
    public BaseResult<Page<ScreenCheckReason>> list(@RequestBody PageVO dto) {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenCheckReasonService.list(dto, userInfoDetailVO);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    @OperLog( systemName = "CCYY", description = "CCSC")
    public BaseResult<String> removeById(@RequestBody ScreenDutyExperienceRemoveDTO screenDutyExperienceRemoveDTO) {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenCheckReasonService.delete(screenDutyExperienceRemoveDTO.getId(), userInfoDetailVO);
    }

    @ApiOperation(value = "保存/修改")
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    @OperLog( systemName = "CCYY", description = "CCBC")
    public BaseResult<String> saveOrUpdate(@RequestBody ScreenCheckReasonDTO screenCheckReasonDTO) {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenCheckReasonService.saveOrUpdate(screenCheckReasonDTO, userInfoDetailVO);
    }
}
